/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GooglePanel.java
 *
 * Created on Dec 13, 2010, 8:04:05 PM
 */

package org.myorg.googletoolbar;

import java.awt.event.KeyEvent;
import java.net.URL;
import org.openide.awt.HtmlBrowser.URLDisplayer;

/**
 *
 * @author jeff.boleng
 */
public class GooglePanel extends javax.swing.JPanel {

    /** Creates new form GooglePanel */
    public GooglePanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jTextField1 = new javax.swing.JTextField();
    jLabel1 = new javax.swing.JLabel();

    jTextField1.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    jTextField1.setText(org.openide.util.NbBundle.getMessage(GooglePanel.class, "GooglePanel.jTextField1.text")); // NOI18N
    jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
      public void keyTyped(java.awt.event.KeyEvent evt) {
        jTextField1KeyTyped(evt);
      }
    });

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\jeff.boleng\\My Documents\\NetBeansProjects\\GoogleToolbar\\google-favicon-16x16.jpg")); // NOI18N
    jLabel1.setText(org.openide.util.NbBundle.getMessage(GooglePanel.class, "GooglePanel.jLabel1.text")); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addComponent(jLabel1)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
        .addComponent(jLabel1)
        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    );
  }// </editor-fold>//GEN-END:initComponents

    private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped
      // TODO add your handling code here:
      int i = evt.getKeyChar();
      if (i == KeyEvent.VK_ENTER)
      {
        try
        {
          URLDisplayer.getDefault().showURL(new URL("http://www.google.com/search?hl=en&q="+jTextField1.getText()+"&btnG=Google+Search"));
        } catch (Exception e) {
          return;
        }
      }
    }//GEN-LAST:event_jTextField1KeyTyped


  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JLabel jLabel1;
  private javax.swing.JTextField jTextField1;
  // End of variables declaration//GEN-END:variables

}
